import java.awt.BorderLayout;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;

/**
 * 
 */

/**
 * @author ikechan
 *
 */
public class HelpBrowser extends JFrame {
    public HelpBrowser(){
        super();

        JEditorPane browser=new JEditorPane();
        browser.setEditable(false);
        browser.setContentType("text/html");

        //String helpHtmlData="<html><body>help</body></html>";
        String helpHtmlData=getHelpData();
        browser.setText(helpHtmlData);


        //gui
        getContentPane().add(new JScrollPane(browser),BorderLayout.CENTER);
    }
    private String getHelpData(){
        try{
            String filename="winchkghelp.html";
            BufferedReader r= new BufferedReader(new InputStreamReader(
                this.getClass().getClassLoader().getResourceAsStream(filename),
                "UTF-8"
            )) ;
            String html= toString(r);
            r.close();

            return html;
        }
        catch(Exception ex){
            ex.printStackTrace();
        }

        return "";
    }
    private static String toString(BufferedReader r) throws IOException{
        StringBuffer sb=new StringBuffer();
        while(true){
            String line=r.readLine();
            if(line==null)
                break;
            sb.append(line);
        }
        return sb.toString();
    }
    public static void main(String[] s){
        JFrame f=new HelpBrowser();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setSize(500,400);
        f.setVisible(true);
    }
}
